package com.woniuxy.lifeorder.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.lifeorder.service.entity.BusinessGoods;
import com.woniuxy.lifeorder.service.mapper.BusinessGoodsMapper;
import com.woniuxy.lifeorder.service.service.BusinessGoodsService;
import com.woniuxy.lifeorder.service.vo.BusinessGoodsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商家服务/产品表 服务实现类
 * </p>
 *
 * @author 陈瑜洲、吴继明
 * @since 2020-09-27
 */
@Service
public class BusinessGoodsServiceImpl extends ServiceImpl<BusinessGoodsMapper, BusinessGoods> implements BusinessGoodsService {
@Autowired
private BusinessGoodsMapper businessGoodsMapper;

    /**
     * 商品分页+条件查询
     * @param current
     * @param size
     * @param businessGoods
     * @return
     */
    @Override
    public BusinessGoodsVO quary_goods(Integer current, Integer size, BusinessGoods businessGoods) {
        BusinessGoodsVO businessGoodsVO=new BusinessGoodsVO();
        IPage<BusinessGoods> page=new Page<>(current,size);
        QueryWrapper qw=new QueryWrapper();
        if (businessGoods.getGoodsId()!=null){
            qw.eq("GOOD_ID",businessGoods.getGoodsId());
        }
        if (businessGoods.getGoodsNumber()!=null&&businessGoods.getGoodsNumber()!=""){
            qw.eq("GOODS_NUMBER",businessGoods.getGoodsNumber());
        }
        if (businessGoods.getBusinessId()!=null){
            qw.eq("BUSINESS_ID",businessGoods.getBusinessId());
        }
        if (businessGoods.getFlag()!=null){
            qw.eq("FLAG",businessGoods.getFlag());
        }
        IPage iPage = businessGoodsMapper.selectPage(page, qw);
        businessGoodsVO.setCurrent(current);
        businessGoodsVO.setSize(size);
        businessGoodsVO.setBusinessGoodsList(iPage.getRecords());
        businessGoodsVO.setTotal(iPage.getTotal());
        return businessGoodsVO;
    }
}
